import json

import requests


class Method:
    GET = "GET"
    POST = "POST"
    PUT = "PUT"
    DELETE = "DELETE"


def req(method, url, headers=None, body=None):
    response = requests.request(method=method, url=url, headers=headers, json=body)
    parse_res = json.loads(response.text)
    if "error" in parse_res:
        raise Exception(parse_res['error'])
    return parse_res

